<?php

/**
 * 账户管理
 * @author renpper
 */
namespace Admin\Controller;
use Lib\Controller;
class WeixinController extends BaseController {
	
	private $weixin_model;
	
	public function _initialize(){
		$this->weixin_model = getInstance('Admin\Model\WeixinModel');
	}

	/**
	 * 修改密码
	 */
	public function setPwd(){
		$username = $_SESSION['SESSION_USER']['username']; 
		if(count($_POST) > 0){
			$datas = $this->getFormParams();
			$old_password = md5($datas['old_password']);
			$new_password = $datas['new_password'];
			$new_password2 = $datas['new_password2'];
			
			$pwd_len = strlen($new_password);
			if($new_password != $new_password2){
				$this->ajaxReturn(300, '新密码跟确认密码不一致');
			}else if($pwd_len<6 || $pwd_len >8){
				$this->ajaxReturn(300, '密码长度必须限制在6~8位之间');
			}
			$manager_info = $this->manager_model->field('uid')->where("username='{$username}' AND password='{$old_password}'")->select();
			if(!$manager_info){
				$this->ajaxReturn(300, '输入的旧密码错误');
			}else{
				$this->manager_model->where("uid={$manager_info['uid']}")->update(array('password'=>md5($new_password)));
				$this->ajaxReturn(200, '密码修改成功');
			}
		}
		$this->assign('username', $username);
		$this->display('../View/System/setPwd.php');
	}

    /**
     * 显示PHP配置信息
     */
    public function phpInfo(){
    	phpinfo();
    }
    
    
}
?>